<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //桶排序
        //选创建桶,在遍历数组索引放入桶中
        //先排空数组个数，在从桶中重新提取
       var arr=[23,12,4,6]
        function bubble(arr){
            var bucket = []
            for(var i = 0 ; i <arr.length ; i++){
                bucket[arr[i]] ='water'
            }
            arr.length = 0
            for(var j in bucket){
                arr.push(Number(j))
            }
            return arr
        }
   console.log(bubble(arr))
    </script>
</body>
</html>